package org.example.model.PoJo;

import org.example.model.Enum.OrderStatus;

import java.time.LocalDateTime;
import java.util.List;
import java.util.stream.Collectors;

public class Order {

    private String orderId;          //订单id
    private List<Item> items;            //商品列表
    private OrderStatus status;            //订单状态
    private double totalPrice;            //订单金额
    private LocalDateTime createTime;     //创建时间


    public Order(String orderId, List<Item> items, OrderStatus status, double totalPrice, LocalDateTime createTime) {
        this.orderId = orderId;
        this.items = items;
        this.status = status;
        this.totalPrice = totalPrice;
        this.createTime = createTime;
    }

    public String getOrderId() {
        return orderId;
    }

    public void setOrderId(String orderId) {
        this.orderId = orderId;
    }

    public LocalDateTime getCreateTime() {
        return createTime;
    }

    public void setCreateTime(LocalDateTime createTime) {
        this.createTime = createTime;
    }

    public double getTotalPrice() {
        return totalPrice;
    }

    public void setTotalPrice(double totalPrice) {
        this.totalPrice = totalPrice;
    }

    public OrderStatus getStatus() {
        return status;
    }

    public void setStatus(OrderStatus status) {
        this.status = status;
    }

    public List<Item> getItems() {
        return items;
    }

    public void setItems(List<Item> items) {
        this.items = items;
    }

    @Override
    public String toString() {
        // 手动拼接items内容
        String itemsStr = items.stream()
                .map(item -> item.toString())
                .collect(Collectors.joining(", ", "[", "]"));
        return "Order{" +
                "orderId='" + orderId + '\'' +
                ", items=" + itemsStr +
                ", status=" + status +
                ", totalPrice=" + totalPrice +
                ", createTime=" + createTime +
                '}';
    }
}
